

import {createApi} from "@reduxjs/toolkit/query/react";
import useBaseQuery from "@/hooks/useBaseQuery";

export const videoAndPictrueApi = createApi({
    reducerPath:'videoAndPictrueApi',
    baseQuery:useBaseQuery('mm'),
    endpoints(build) {
      return {
        getTaskList:build.query({
          query:(data:any) => {
            return {
              url: 'mmVideoPub/list',
              method:"get",
              params:data,
              openErrMessage: true
            }
          },
        }),
        genVideo:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmViewGeneration/genVideoByText',
              method:"post",
              body:data,
              openErrMessage: true
            }
          },
        }),
        genPictrue:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmViewGeneration/genPicByText',
              method:"post",
              body:data,
              openErrMessage: true
            }
          },
        }),
        queryTaskStatus:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmViewGeneration/queryTaskStatusByIds?ids=' + data.ids,
              method:"get",
              openErrMessage: true
            }
          },
        }),
        getWorks:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmViewGeneration/list',
              method:"get",
              params: data,
              openErrMessage: true
            }
          },
        }),
        deleteBatch:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmViewGeneration/deleteBatch?ids=' + data.ids,
              method:"delete",
              openErrMessage: true
            }
          },
        }),
        getGenList:build.query({
          query:(data:any) => {
            return {
              url: 'mmViewGeneration/list',
              method:"get",
              params: data,
              openErrMessage: true
            }
          },
        }),
        reGenerate:build.mutation({
          query:(data:any) => {
            return {
              url: 'mmViewGeneration/reGenerate?id=' + data.id,
              method:"post",
              openErrMessage: true
            }
          },
        }),
      }
    }
});

export const {
    useGenVideoMutation,
    useGenPictrueMutation,
    useQueryTaskStatusMutation,
    useGetWorksMutation,
    useDeleteBatchMutation,
    useGetGenListQuery,
    useReGenerateMutation,
} = videoAndPictrueApi;
